#include "myMath.h"
#include "math.h"

double Math::min(double* vals, int size)
{
    if (size < 1)
        return 0.0;

    double min = vals[0];
    for (int i=1; i<size; i++)
        if (vals[i] < min)
            min = vals[i];

    return min;
}

double Math::max(double* vals, int size)
{
    if (size < 1)
        return 0.0;

    double max = vals[0];
    for (int i=1; i<size; i++)
        if (vals[i] > max)
            max = vals[i];

    return max;
}

double Math::mean(double* vals, int size)
{
    double tot = 0;

    for (int i=0; i<size; i++)
        tot += vals[i];

    return tot / size;
}

double Math::tanh(double val)
{
    double temp = exp(2 * val);
    return (temp - 1) / (temp + 1);
}
